// 引入一级路由组件

// import Home from '@/views/Home/home.vue'
// import Login from '@/views/Login/login.vue'
// import Register from '@/views/Register/register.vue'
// import Search from '@/views/Search/search.vue'
// import Detail from '@/views/Detail/index.vue'
// import AddCartSuccess from '@/views/AddCartSuccess/index.vue'
// import shopCart from '@/views/ShopCart/index.vue'
// import Trade from '@/views/Trade/index.vue'
// import Pay from '@/views/Pay/index.vue'
// import PaySuccess from '@/views/PaySuccess/index.vue'
// import Center from '@/views/Center/index.vue'

// 引入二级路由组件
// import MyOrder from '@/views/Center/myOrder/index.vue'
// import GroupOrder from '@/views/Center/groupOrder/index.vue'

// 路由配置信息
// 路由懒加载

export default [{
        path: "/center",
        component: () =>
            import ('@/views/Center/index.vue'),
        meta: { show: true },
        // 子路由
        children: [{
                path: "myorder",
                component: () =>
                    import ('@/views/Center/myOrder/index.vue')
            },
            {
                path: "grouporder",
                component: () =>
                    import ('@/views/Center/groupOrder/index.vue')
            },
            {
                path: "/center",
                redirect: "/center/myorder"
            }
        ]
    },
    {
        path: "/paysuccess",
        component: () =>
            import ('@/views/PaySuccess/index.vue'),
        meta: { show: true },
        // 路由独享守卫
        // beforeEnter: (to, from, next) => {
        // 必须是从支付页来
        //     if (from.path == "/pay") {
        //         next()
        //     } else {
        //         next(false)
        //     }
        // }
    },
    {
        path: "/pay",
        component: () =>
            import ('@/views/Pay/index.vue'),
        meta: { show: true },
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            // 必须是从交易页来
            if (from.path == "/trade") {
                next()
            } else {
                next(false)
            }
        }
    },
    {
        path: "/trade",
        component: () =>
            import ('@/views/Trade/index.vue'),
        meta: { show: true },
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            // 必须是从购物车来
            if (from.path == "/shopcart") {
                next()
            } else {
                next('/shopcart')
            }
        }
    },
    {
        path: "/shopcart",
        component: () =>
            import ('@/views/ShopCart/index.vue'),
        meta: { show: true }
    },
    {
        path: "/addcartsuccess",
        name: "addcartsuccess",
        component: () =>
            import ('@/views/AddCartSuccess/index.vue'),
        meta: { show: true }
    },
    {
        path: "/detail/:skuid",
        component: () =>
            import ('@/views/Detail/index.vue'),
        meta: { show: true }
    },
    {
        path: "/home",
        component: () =>
            import ('@/views/Home/home.vue'),
        meta: { show: true }
    },
    {
        path: "/login",
        component: () =>
            import ('@/views/Login/login.vue'),
        meta: { show: false }
    },
    {
        path: "/register",
        component: () =>
            import ('@/views/Register/register.vue'),
        meta: { show: false }
    },
    {
        path: "/search/:keyword?",
        component: () =>
            import ('@/views/Search/search.vue'),
        meta: { show: true },
        name: "search"
    },
    {
        path: "*",
        redirect: '/home'
    }
]